package com.Lyoto.NetNotify.Handler.impl;

import cn.hutool.json.JSONUtil;
import com.Lyoto.NetNotify.Config.EmailClient;
import com.Lyoto.NetNotify.Constraint.NetConfig;
import com.Lyoto.NetNotify.Handler.PushRegistrar;
import lombok.extern.slf4j.Slf4j;

/***
 @author Lyoto
 @description
 @create 2024/3/17-16:11
 ***/
@Slf4j
public class EmailPusher implements PushRegistrar {
    private EmailClient emailClient;
    public EmailPusher() {
        log.info("推送启动加载项|正在配置邮件推送……");
        configEmail();
    }

    public void configEmail(){
        this.emailClient = new EmailClient();
    }

    @Override
    public void pushOn() {
        String ip = JSONUtil.createObj().set("ip", NetConfig.getIp()).toJSONString(0);
        emailClient.sendNotifyEmail(ip);
    }
}
